<?php
/**
 * Created by PhpStorm.
 * User: 17208
 * Date: 2020/10/15
 * Time: 11:18
 */

namespace extend;


class Common
{
    /** 解析淘口令 */
    public static function findKeyword($content){
        $reg = "#^找(.+)#isu";
        return preg_match ($reg, $content, $m)==false ? '' : $m[1];
    }
    /** 解析淘口令 */
    public static function tbkParsePassword($content){
        $symbol = "\₰|\/|\//|\¥|\\(|\\)|\《|\￥|\€|\\$|\₤|\₳|\¢|\¤|\฿|\฿|\₵|\₡|\₫|\₲|\₭|£|\₥|\₦|\₱|\〒|\₮|\₩|\₴|\₪|\៛|\﷼|\₢|\ℳ|\₯|\₠|\₣|\₧|\ƒ";
        $reg = "#[{$symbol}]([a-zA-Z0-9]{11})[{$symbol}]#isu";
        $password = preg_match ($reg, $content, $m)==false ? '' : $m[1];
        if($password) return $password;
        $reg = "#([a-zA-Z0-9]{11})#isu";
        return preg_match ($reg, $content, $m)==false ? '' : $m[1];
    }
    /** 解析淘宝连接的商品ID */
    public static function parseUrlItemId($url){
        $data = parse_url($url);
        $reg = "#\/i([0-9]+).htm#isu";
        return preg_match ($reg, $data['path'], $m)==false ? '' : $m[1];
    }
}